import Vue from 'vue'
import App from './App.vue'
import Vuetify from 'vuetify';
import { router } from '@/routes';
import store from '@/store';
import i18n from '@/locales';
import '@/components';
import 'vuetify/dist/vuetify.min.css';
import '@/styles/base.less';
import { Site, ServiceFee, OrderStatus, TaskType, PayMethod, IncomeType, TaskStatus, BuyerStatus, Country, Platform, TopupStatus } from './utils/constants';
declare const window: any;

Vue.config.productionTip = false

Vue.use(Vuetify, {
  theme: {
    primary: '#4FC3F7',
    secondary: '#0288D1',
    accent: '#4DB6AC',
    error: '#F44336',
    light: '#f1f1f1',
    dark: '#909090'
  },
});

/**
 * 订单状态过滤器
 */
Vue.filter('OrderStatus', (val: any) => {
  let status = '未知状态'
  if (val + '') {
    status = OrderStatus[val];
  }
  return status;
});

Vue.filter('TaskStatus', (val: any) => {
  let status = '未知状态'
  if (val + '') {
    status = TaskStatus[val + ''];
  }
  return status;
});
Vue.filter('TopupStatus', (val: any) => {
  let status = '未知状态'
  if (val + '') {
    status = TopupStatus[val + ''];
  }
  return status;
});

Vue.filter('BuyerStatus', (val: any) => {
  let status = '未知状态'
  if (val + '') {
    status = BuyerStatus[val];
  }
  return status;
});

/**
 * 订单状态过滤器
 */
Vue.filter('TaskType', (val: any) => {
  let status = '未知状态'
  if (val + '') {
    status = TaskType[val];
  }
  return status;
});

/**
 * 性别过滤器
 */
Vue.filter('Gender', (val: any) => {
  let gender = '无'
  if (val == '1') {
    gender = '男'; 
  } else {
    gender = '女'; 
  }
  return gender;
});

/**
 * 性别过滤器
 */
Vue.filter('Platform', (val: any) => {
  let platform = '无'
  if (val == 1) {
    platform = 'Amazon'; 
  }
  return platform;
});


Vue.filter('ServiceFeeFilter', (val: any) => {
  if (!(val + '')) {
    return '未知'
  }
  return ServiceFee[val];
});

Vue.filter('Site', (val: any) => {
  if (!(val + '')) {
    return '未知站点'
  }
  return Site[val];
});


Vue.filter('PayMethod', (val: any) => {
  let status = '未知'
  if (val + '') {
    status = PayMethod[val];
  }
  return status;
});
/**
 * 流水类型
 */
Vue.filter('IncomeType', (val: any) => {
  let status = '未知状态'
  if (val + '') {
    status = IncomeType[val];
  }
  return status;
});

Vue.filter('Platform', (val: any) => {
  if (!(val + '')) {
    return '未知'
  }
  return Platform[val];
});
Vue.filter('Country', (val: any) => {
  if (!(val + '')) {
    return '未知'
  }
  return Country[val];
});

document.addEventListener('DOMContentLoaded', () => {
  const $Vue = new Vue({
    router,
    store,
    i18n,
    render: (h) => h(App),
  });
  window.$Vue = $Vue;
  $Vue.$mount('#app');
});